package com.springdemo.spring5.service;

import com.springdemo.spring5.dao.UserDao;
import com.springdemo.spring5.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: zjz
 * Date: 2022/02/28 15:31
 * Description:
 * Version: V1.0
 */
@Service(value = "userservice")
public class UserService {
    @Autowired
    //注入UserDao
    private UserDao userDao;

    /**
     * 添加User
     * @param user
     */
    public void addUser(User user){
        userDao.add(user);
    }

    /**
     * 根据id删除User
     * @param id
     */
    public void deleteUser(int id){
        userDao.delete(id);
    }

    /**
     * 根据id修改User
     * @param user
     */
    public void updateUser(User user){
        userDao.update(user);
    }

    public int findcount(){
        return userDao.count();
    }

    public User findUserInfo(int id){
        return userDao.UserInfo(id);
    }

    public List<User>userList(){
        return userDao.all();
    }

    public void batchAdd(List<Object[]> batchList){
        userDao.batchAdd(batchList);
    }

    public void batchUpdate(List<Object[]> batchList){
        userDao.batchUpdate(batchList);
    }

    public void batchDelete(List<Object[]> batchList){
        userDao.batchDelete(batchList);
    }
}
